package design2.builder.example.components;

/**
 * 只是汽车的另一个特点。
 * 发动机
 */
public class Engine {

	private final double volume; //体积
	private double mileage; //里程
	private boolean started; //启动


	public Engine(double volume, double mileage) {
		this.volume = volume;
		this.mileage = mileage;
	}

	public double getVolume() {
		return volume;
	}

	public double getMileage() {
		return mileage;
	}
	public boolean isStarted(){
		return  this.started;
	}

	public void on(){
		this.started=true;
	}

	public void off(){
		this.started=false;
	}


	public void go(){
		if(this.started){
			this.mileage+=mileage;
		}else{
			System.out.println("不能走，你必须先启动发动机！");
		}
	}

}
